package com.online.shopping.service.impl;

import com.online.shopping.mapper.TbBrandMapper;
import com.online.shopping.pojo.TbBrand;
import com.online.shopping.service.GoodBrandsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class GoodBrandsServiceImpl implements GoodBrandsService {

	@Autowired
	private TbBrandMapper tbBrandMapper;

	@Override
	public List<TbBrand> findAllTbBrandByPage() {
		return tbBrandMapper.selectByExample(null);
	}

	@Override
	public TbBrand findTbBrandById(Long id) {
		return tbBrandMapper.selectByPrimaryKey(id);
	}

	@Override
	public void addTbBrand(TbBrand brand) {
		tbBrandMapper.insert(brand);
	}

	@Override
	public void updateTbBrand(TbBrand brand) {
		tbBrandMapper.updateByPrimaryKey(brand);
	}

	@Override
	public void delete(Long[] ids) {
		for(Long id : ids){
			tbBrandMapper.deleteByPrimaryKey(id);
		}
	}

	@Override
	public List findBrandList() {
		return tbBrandMapper.selectOptionList();
	}
}
